<template>
	<view>
		<!-- 懒加载动画 -->
		<view class="loading-box">
			<u-loading :show="loadingone" color="#41ADBA" size="70"></u-loading>
		</view>
		<view v-show="isLoadingOver">
			<navbar name="健康档案"></navbar>
			<view v-show="!isShow" class="message-box" @tap="switchover('isShow',true)">
				<view class="title-dn">
					基本信息
				</view>
			</view>
			<view class="w706" v-show="isShow">
				<!-- 标题 -->
				<view class="materials-title">
				</view>
				<view class="materials-title2" @tap="switchover('isShow',false)">
					基本信息
				</view>
				<!-- end -->
				<!-- <block v-for="(item,idx) in basic" :key="idx"> -->
				<view class="weui-flex materia">
					<view class="flex-title">
						姓名
					</view>
					<view class="flex-num">
						<input class="flex-input" type="text" v-model="result.basicInfo.userName" @blur="nameAlter" />
					</view>
				</view>
				<u-line />
				<view class="weui-flex materia">
					<view class="flex-title">
						性别
					</view>
					<view class="flex-num optional">
						<input v-if="!result.basicInfo.sex" class="flex-input" type="text" :disabled="true"
							:value="'请选择'" @tap="clickInput('gender')" />
						<input v-else class="flex-input" type="text" :disabled="true"
							:value="result.basicInfo.sex ==1?'男':(result.basicInfo.sex ==2?'女':'未知')" @tap="clickInput('gender')" />
					</view>
				</view>
				<u-line />
				<view class="weui-flex materia">
					<view class="flex-title">
						生日
					</view>
					<view class="flex-num optional">
						<input class="flex-input" type="text" :disabled="true"
							:value="result.basicInfo.birthday || '请选择'" @tap="clickInput('birthday')" />
					</view>
				</view>
				<u-line />
				<view class="weui-flex materia">
					<view class="flex-title">
						身高
					</view>
					<view class="flex-num optional">
						<input class="flex-input" type="text" :disabled="true" :value="result.basicInfo.height || '请选择'"
							@tap="clickInput('height')" />
					</view>
				</view>
				<u-line />
				<view class="weui-flex materia">
					<view class="flex-title">
						体重
					</view>
					<view class="flex-num optional">
						<input class="flex-input" type="text" :disabled="true" :value="result.basicInfo.weight || '请选择'"
							@tap="clickInput('weight')" />
					</view>
				</view>
				<u-line />
				<view class="weui-flex materia">
					<view class="flex-title">
						bmi
					</view>
					<view class="flex-num optional">
						<input class="flex-input" type="text" :disabled="true" :value="result.basicInfo.bmi || '请选择'"
							@tap="clickInput('bmi')" />
					</view>
				</view>
				<!-- </block> -->
				<view class="packUp">
					<text class="clickhide" @tap="switchover('isShow',false)">点击收起</text>
				</view>
			</view>
			<!-- 健康信息 -->
			<view class="message-box" v-show="!healthInfoIsshow" @tap="switchover('healthInfoIsshow',true)">
				<view class="title-dn">
					健康信息
				</view>
				<view class="perfect-text" v-if="healthInfoPerfect">
					立即完善信息
				</view>

			</view>
			<view class="w706" v-show="healthInfoIsshow">
				<!-- 标题 -->
				<view class="materials-title">
				</view>
				<view class="materials-title2" @tap="switchover('healthInfoIsshow',false)">
					健康信息
				</view>
				<view class="wview-body" v-for="(item,idx) in result.healthInfo" :key="idx">
					<view class="flex-titlea">
						{{item.healthName}}
					</view>
					<view class="wview-flex" v-for="(items,idxs) in item.healthList" :key="idxs">
						<view class="flex-leftView">
							{{items.name}}
						</view>
						<view class="flex-rView"
							@tap="amend(items,idx,'healthInfo',item.healthList,idxs,item.healthName,items.value)">
							{{items.value?items.value:'请完善'}}
						</view>
					</view>
					<u-line />
				</view>
				<view class="packUp">
					<text class="clickhide" @tap="switchover('healthInfoIsshow',false)">点击收起</text>
				</view>
			</view>
			<!-- 生活习惯  -->
			<view class="message-box" v-show="!livingHabitsIsshow" @tap="switchover('livingHabitsIsshow',true)">
				<view class="title-dn">
					生活习惯
				</view>
				<view class="perfect-text" v-if="livingHabitsPerfect">
					立即完善信息
				</view>
			</view>
			<view class="w706" v-show="livingHabitsIsshow">
				<!-- 标题 -->
				<view class="materials-title">
				</view>
				<view class="materials-title2" @tap="switchover('livingHabitsIsshow',false)">
					生活习惯
				</view>
				<view class="wview-body" v-for="(item,idx) in result.livingHabits" :key="idx">
					<view class="flex-titlea">
						{{item.healthName}}
					</view>
					<view class="wview-flex" v-for="(items,idxs) in item.healthList" :key="idxs">
						<view class="flex-leftView">
							{{items.name}}
						</view>
						<view class="flex-rView"
							@tap="amend(items,idx,'livingHabits',item.healthList,idxs,item.healthName,items.value)">
							{{items.value?items.value:'请设置'}}
						</view>
					</view>
					<u-line />
				</view>
				<view class="packUp">
					<text class="clickhide" @tap="switchover('livingHabitsIsshow',false)">点击收起</text>
				</view>
			</view>
			<!-- 心理状况  -->
			<view class="message-box" v-show="!physiologyConditionIsshow" @tap="switchover('physiologyConditionIsshow',true)">
				<view class="title-dn">
					心理状况
				</view>
				<view class="perfect-text" v-if="physiologyConditionPerfect">
					立即完善信息
				</view>
			</view>
			<view class="w706" v-show="physiologyConditionIsshow">
				<!-- 标题 -->
				<view class="materials-title">
				</view>
				<view class="materials-title2" @tap="switchover('physiologyConditionIsshow',false)">
					心理状况
				</view>
				<view class="wview-body" v-for="(item,idx) in result.physiologyCondition" :key="idx">
					<view class="flex-titlea">
						{{item.healthName}}
					</view>
					<view class="wview-flex" v-for="(items,idxs) in item.healthList" :key="idxs">
						<view class="flex-leftView">
							{{items.name}}
						</view>
						<view class="flex-rView"
							@tap="amend(items,idx,'physiologyCondition',item.healthList,idxs,item.healthName,items.value)">
							{{items.value?items.value:'请设置'}}
						</view>
					</view>
					<u-line />
				</view>
				<view class="packUp">
					<text class="clickhide" @tap="switchover('physiologyConditionIsshow',false)">点击收起</text>
				</view>
			</view>
			<!-- 检查数据   -->
			<view class="message-box" v-show="false">
				<view class="title-dn">
					体检报告
				</view>
				<view class="perfect-text">
					立即完善信息
				</view>
			</view>
			<!-- 标题 -->
			<!-- <view class="w706">
				<view class="materials-title">
				</view>
				<view class="materials-title2" @click="isShow = false">
					体检报告
				</view>
				<block v-for="(item,idx) in reportList" :key="idx">
					<view class="reportView">
						<view class="report-icon">
							<u-lazy-load height="55" img-mode="aspectFill"
								image="http://static.bsyjk.cn/reporticon/037F7DDF02E44EA0B9FABCE2AF9A7747.png"></u-lazy-load>
						</view>
						<view class="report-c">
							<view class="report-title">
								{{item.title}}
							</view>
							体检时间：{{item.time}}
						</view>
						<view class="report-r">
							<text class="report-result" :class="[item.result=='解读中'?'color-jd':'',item.result=='已完成'?'color-wc':'']">{{item.result}}</text>
						</view>
					</view>
					<u-line />
				</block>
				<view class="uploading-view">
					<text class="uploading-pr">上传报告</text>
				</view>
				<view class="packUp">
					<text class="clickhide" @click="isShow = false">点击收起</text>
				</view>
			</view> -->
			<!-- 日期选择 -->
			<!-- 年龄 -->
			<lb-picker ref="picker1"
			  v-model="value1"
			  :start-date="starDate"
			  :end-date="endTime"
			  mode="dateSelector"
			  @change="handleChange"
			  @confirm="handleConfirmSr"
			  @cancel="handleCancel">
			</lb-picker>
			<!-- <lb-picker ref="picker1" v-model="value1" :start-date="starDate" :end-date="endTime" mode="dateSelector"
				@change="handleChange" @confirm="handleConfirmSr" @cancel="handleCancel">
			</lb-picker> -->
			<!-- end -->
			<!-- 体重 -->
			<lb-picker ref="picker2" v-model="value2" mode="unlinkedSelector" :list="list2" @change="handleChange"
				@confirm="handleConfirmW" @cancel="handleCancel">
			</lb-picker>
			<!--身高 -->
			<lb-picker ref="picker3" v-model="value3" mode="unlinkedSelector" :list="list3" @change="handleChange"
				@confirm="handleConfirmH" @cancel="handleCancel">
			</lb-picker>
			<!-- 性别 -->
			<lb-picker ref="picker4" v-model="value4" mode="selector" :list="list4" :dataset="{ name: 'label4' }"
				@change="handleChange" @confirm="handleConfirmXb" @cancel="handleCancel">
			</lb-picker>
			<lb-picker ref="picker5" v-model="value5" mode="selector" :list="list5" :dataset="{ name: 'label4' }"
				@change="handleChange" @confirm="handleConfirm" @cancel="handleCancel">
			</lb-picker>
			<!-- 单选 -->
			<selecta ref="radio" :maskLayer="maskLayer" :current="radioIndex" :ydPopup="true" :checkedData="{}"
				:items="items" :mode="'radio'" :ifForm="false" @cancel="radioChange" @descriptionAdd="descriptionAdd"
				@RadioData="RadioData"></selecta>
			<!-- 多选 -->
			<selecta ref="checkbox" :maskLayer="maskLayer" :ydPopup="false" :checkedData="{}" :items="items"
				:mode="'checkboxDan'" :healthName="healthName" :centerText="'多选'" :confirmText="'确认'" @itemsa="itemsa"
				@descriptionAdd="descriptionAdd" :ifForm="false" @checkboxData="checkboxData" @other="other">
			</selecta>
			<!-- 公共滑动选择 -->
			<lb-picker ref="picker40" v-model="publicvalue" mode="selector" :list="publicList" @change="handleChange"
				@confirm="handleConfirmBase" @cancel="handleCancel">
			</lb-picker>
		</view>
	</view>
</template>

<script>
import selecta from '../../components/lb-picker/select.vue';
	import lbPicker  from '../../components/lb-picker/index.vue';

	import uLoading from "@/uview-ui/components/u-loading/u-loading.vue"

import uLine from "@/uview-ui/components/u-line/u-line.vue"
import uLazyLoad from "@/uview-ui/components/u-lazy-load/u-lazy-load.vue"


	export default {
		components: {
			uLoading,
			uLine,
			uLazyLoad,
			selecta,
			lbPicker
		},
		data() {
			return {
				allOther:{},//所有其他
				healthName:'',
				physiologyConditionPerfect:true,//心理状况
				livingHabitsPerfect:true,//生活习惯
				healthInfoPerfect:true,//健康信息
				pagetype:'',
				physiologyConditionIsshow:false,
				starDate: '1900-12-31', //开始时间
				endTime: this.$basejs.thisdayFormat2(false), //结束时间默认今天
				valueArr: [],
				loadingone: false, //懒加载
				detailId: '', //单选滑动用到
				index1: '', //数组一级修改值
				index2: '', //数组二级修改值
				listtype: '',
				radioIndex: 9999, //视图未选择
				healthList: '', //当前点击的数据列表
				itemType: '', //当前选择器参数
				publicvalue: '', //公共的滑动选择
				publicSlideLabel: '', //公共的滑动选择
				publicList: [], //公共的滑动选择
				items: [], //公共的单选
				maskLayer: true,
				livingHabitsIsshow: false, //生活习惯是否展开
				healthInfoIsshow: false, //健康信息展开
				result: '', //数据所有
				value5: '请选择血型',
				list5: ['A', 'B', 'C', 'D', 'AB', 'O'],
				value4: '请选择性别',
				list4: [{
						label: '男',
						value: 1
					},
					{
						label: '女',
						value: 2
					}
				],
				// 身高体重 时间
				value2: ['请选择体重'],
				value1: '',
				label: '请选择时间',
				list2: [],
				value3: ['请选择身高'],
				list3: [],
				// end
				isShow: true,
				isLoadingOver: false, //加载是否完成
			}
		},
		computed: {
			// 是否全部选中
			all_checked() {
				console.log(this.result,338)

				let healthInfo = this.result.healthInfo,
				livingHabits = this.result.livingHabits,
				physiologyCondition = this.result.physiologyCondition;
				if (healthInfo) {
					this.healthInfoPerfect = this.perfectFun(healthInfo)//健康信息
				}
				if (livingHabits) {
					this.livingHabitsPerfect = this.perfectFun(livingHabits)//生活习惯
				}
				if (physiologyCondition) {
					this.physiologyConditionPerfect = this.perfectFun(physiologyCondition)//心理状况
				}
			}
		},
		onLoad(e) {
			this.pagetype = e.type;
			let list3 = [],
				list2 = [];
			for (let i = 100; i < 241; i++) { //身高数组
				list3.push({
					value: i,
					label: i
				})
			}
			for (let i = 25; i < 301; i++) { //体重
				list2.push({
					value: i,
					label: i
				})
			}
			let ninArr = [];
			for(let i = 0;i<10;i++){
				ninArr.push(i)
			}
			this.list2 = [list2,ninArr, ['kg']] //体重
			this.list3 = [list3, ['cm']] //身高数组
			this.userArchives()
		},
		methods: {
			other(e){
				this.allOther[this.listtype]= {
					otherValue:e.detail.value
				}
			},
			perfectFun(dataList){
				let perfect = false;
				for(let i = 0;i<dataList.length;i++){
					let healthList = dataList[i].healthList;
					for(let j = 0;j<healthList.length;j++){
						if(healthList[j].value == ''||healthList[j].value == null){//有未完善
							perfect = true
						}
					}
				}
				console.log(perfect,350000000)
				return perfect
			},
			itemsa(data) {
				console.log(data)
			},
			// 修改体重
			handleConfirmW(e) {
				this.result.basicInfo.weight = e.value[0]+'.'+e.value[1]
				this.result.paperId = ''
				this.result.kindId = 1
				this.result.detailId = ''
				this.result.healthName = '基本信息'
				this.updateByUserId(this.result)
			},
			// 修改身高
			handleConfirmH(e) {

				this.result.basicInfo.height = e.value[0]
				this.result.paperId = ''
				this.result.kindId = 1
				this.result.detailId = ''
				this.result.healthName = '基本信息'
				this.updateByUserId(this.result)
				if(this.result.basicInfo.sex&&this.result.basicInfo.birthday&&this.result.basicInfo.height&&this.pagetype == 'perfect'){
					wx.showModal({
						title: '提示',
						content: '可以继续测量啦!',
						showCancel: false,
						success: function(res) {
							uni.navigateBack({
								delta: 1
							});
						}
					})
				}
			},
			// 修改生日
			handleConfirmSr(e) {
				console.log(e)
				this.result.basicInfo.birthday = e.value;
				this.result.paperId = ''
				this.result.kindId = 1
				this.result.detailId = ''
				this.result.healthName = '基本信息'
				this.updateByUserId(this.result)
				if(this.result.basicInfo.sex&&this.result.basicInfo.birthday&&this.result.basicInfo.height&&this.pagetype == 'perfect'){
					wx.showModal({
						title: '提示',
						content: '可以继续测量啦!',
						showCancel: false,
						success: function(res) {
							uni.navigateBack({
								delta: 1
							});
						}
					})
				}
			},
			// 修改性别
			handleConfirmXb(e) {
				console.log(e)
				this.result.basicInfo.sex = e.value
				this.result.paperId = ''
				this.result.kindId = 1
				this.result.detailId = ''
				this.result.healthName = '基本信息'
				this.updateByUserId(this.result)
				if(this.result.basicInfo.sex&&this.result.basicInfo.birthday&&this.result.basicInfo.height&&this.pagetype == 'perfect'){
					wx.showModal({
						title: '提示',
						content: '可以继续测量啦!',
						showCancel: false,
						success: function(res) {
							uni.navigateBack({
								delta: 1
							});
						}
					})
				}
			},
			// 修改昵称
			nameAlter(e) {
				console.log(e)
				let value = e.detail.value;
				this.result.basicInfo.userName = value
				this.result.paperId = ''
				this.result.kindId = 1
				this.result.detailId = ''
				this.result.healthName = '基本信息'
				this.updateByUserId(this.result)
			},
			// 多选提交
			checkboxData(data) {
				console.log(data)
				let listtype = this.listtype,
					index1 = this.index1,
					index2 = this.index2;
				if (data.type == 'formhide') { //多选提交
					let items = this.items,
						valueArr = [],
						detailId = '';
					for (let i = 0; i < items.length; i++) {
						if (items[i].checked&&items[i].value=='其他') {
							valueArr.push(this.allOther[listtype]?this.allOther[listtype].otherValue:items[i].value)
							detailId = items[i].detailId
						}else if (items[i].checked){
							valueArr.push(items[i].value)
							detailId = items[i].detailId
						}
					}
					this.result.detailId = detailId;
					this.result[listtype][index1].healthList[index2].value = valueArr.join(',')
					this.updateByUserId(this.result)
				} else if (data.type == 'reset') {
					for (let i = 0; i < this.items.length; i++) {
						this.items[i].checked = false
					}
				} else {
					console.log(this.items[data.index].value == '无' || data.value == '9999999999999999', '381111111111')
					if (this.items[data.index].value == '无' || data.value == '9999999999999999') {
						if (this.items[data.index].checked == false) {
							for (let i = 0; i < this.items.length; i++) {
								this.items[i].checked = false
							}
						}
					}
					if (this.items[0].value == '无' && this.items[0].checked == false || data.index == 0) { //没选中无的状态
						this.items[data.index].checked = !this.items[data.index].checked
					} else if (this.items[0].value == '无' && this.items[0].checked == true) { //无选中状态
						this.items[0].checked = false
						this.items[data.index].checked = !this.items[data.index].checked
					} else { //没有无 的状态
						let noIndex = 0;
						for(let i = 0;i<this.items.length;i++){
							if(this.items[i].value == '无'){
								noIndex = i
							}
						}
						this.items[noIndex].checked = false//无取消选中
						this.items[data.index].checked = !this.items[data.index].checked
					}

				}
			},
			// 公用的滑动控件
			handleConfirmBase(e) {
				let value = e.value; //获取修改value
				let result = this.result,
					listtype = this.listtype,
					index1 = this.index1,
					index2 = this.index2;
				this.result.detailId = this.detailId; //result提交id
				this.result[listtype][index1].healthList[index2].value = value; //视图
				this.result[listtype][index1].healthList[index2].detailId = this.detailId; //视图组id
				// console.log(value,'公用的滑动控件')
				// 请求修改接口
				this.updateByUserId(this.result)
			},
			updateByUserId(phrVO) {
				let _this = this;
				uni.request({
					data: phrVO,
					header: {
						'Authorization': uni.getStorageSync(global.IS_DEV?'USER_TOKEN_BSY_T':'USER_TOKEN_BSY_Z'),
						'userSource': 1, //用户类型 1:C端用户  2:员工
						'content-type': 'application/json'
					},
					method: 'POST',
					url: global.host+'health-service/userArchives/updateByUserId',
					success(res) {
						if (res.data.code == 1000) {
							_this.userArchives()
						}
					}
				})
				// this.$api.post(global.apiUrls.updateByUserId, fdata)
				// 	.then(res => {
				// 		if (res.data.code == 1000) {

				// 		}
				// 	}).catch(err => {})
			},
			// 单选回调
			RadioData(data) {
				let listtype = this.listtype,
					index1 = this.index1,
					index2 = this.index2;
				this.result.detailId = data.data.detailId;
				this.result[listtype][index1].healthList[index2].value = data.data.value;
				this.result[listtype][index1].healthList[index2].detailId = data.data.detailId;
				// 请求修改接口
				this.updateByUserId(this.result)
			},
			userName(e) {
				this.result.basicInfo.userName = e.detail.value;
			},
			amend(item, index1, type, healthList, index2, healthName, valueArr) {
				// id修改
				this.healthName = healthName
				console.log(healthName)
				this.result.healthName = healthName;
				this.result.paperId = item.paperId;
				this.result.kindId = type == 'livingHabits' ? 3 : 2
				// end
				this.listtype = type;
				this.index1 = index1;
				this.index2 = index2;
				if (valueArr) {
					this.valueArr = valueArr.split(',');
				}
				console.log(item,'47333333333333333333')
				this.itemType = item.type;
				this.healthList = healthList; //点击的数据列表
				this.getByValueByPaperId(item.paperId,valueArr)
			},
			// 展开收起事件
			switchover(name, type) {
				this.isShow = false;
				this.healthInfoIsshow = false;
				this.livingHabitsIsshow = false;
				this.physiologyConditionIsshow = false;
				this[name] = type
				// if (name == 'isShow') {
				// 	this.isShow = type;
				// } else if (name == 'healthInfoIsshow') {
				// 	this.healthInfoIsshow = type;
				// } else if (name == 'livingHabitsIsshow') {
				// 	this.livingHabitsIsshow = type;
				// }
			},
			// 调用控件
			getByValueByPaperId(paperId,valueArr) {
				let _this = this;
				console.log(paperId, 1523)
				this.$api.get(global.apiUrls.getByValueByPaperId + '/' + paperId, {})
					.then(res => {
						if (res.data.code == 1000) {
							let itemType = _this.itemType;
							let result = res.data.result;
							let thislist = [];
							let healthList = _this.healthList; //当前选中数据列表
							if (itemType == 1) { //选择输入
								let value = result[0].value.split('-');
								let i = parseInt(value[0]), //最小值
									maxnum = parseInt(value[1]), //最大值
									publicList = []; //公用list
								for (i; i < maxnum; i++) {
									publicList.push({
										label: i+'',
										value: i+''

									})
								}
								_this.publicvalue = parseInt(valueArr)
								_this.detailId = result[0].detailId;
								_this.publicList = publicList
								_this.$refs['picker40'].show()
								console.log(publicList, maxnum)
							} else if (itemType == 2) { //手动输入
							} else if (itemType == 3) { //单选
								let current = '';
								for (let i = 0; i < result.length; i++) {
									let isRepea = false; //判断是否重复
									for (let j = 0; j < healthList.length; j++) {
										if (result[i].detailId == healthList[j].detailId) {
											console.log('重复！！！！！！！！！！！！！！', i)
											isRepea = true //重复
											current = i //重复索引
											break; //结束
										}
									}
									if (isRepea) { //选中
										result[i].checked = true
									} else { //未选中
										result[i].checked = false
									}
									result[i].label = result[i].value
								}
								_this.items = result;
								console.log(current, 331)
								_this.radioIndex = current
								// _this.$refs['radio'].currenta(current)
								_this.$refs['radio'].show()
							} else if (itemType == 4) { //多选
								let valueArr = _this.valueArr,
								qtArr = JSON.parse(JSON.stringify(_this.valueArr)),
								qtIndex = 0;
								console.log('1563 aaaaaaaaaaaaaa', result, valueArr)
								for (let i = 0; i < result.length; i++) {
									let isRepea = false; //判断是否重复
									if(result[i].value == '其他'){
										qtIndex = i
									}
									for (let j = 0; j < valueArr.length; j++) {
										if (result[i].value == valueArr[j]) {
											console.log('重复！！！！！！！！！！！！！！', i)
											isRepea = true //重复
											delete qtArr[j]
											break; //结束
										}
									}
									if (isRepea) { //选中
										result[i].checked = true
									} else { //未选中
										result[i].checked = false
									}
									result[i].label = result[i].value
								}
								let qtArrq = []
								for(let i = 0;i<qtArr.length;i++){
									if(qtArr[i] != ''&&qtArr[i]!= null){
										qtArrq.push(qtArr[i])
									}
								}
								if(qtArrq.length == 1){
									result[qtIndex].checked = true
									setTimeout(e=>{
										_this.$refs.checkbox.otherValueFun(qtArrq[0])
									},500)
								}else{
									setTimeout(e=>{
										_this.$refs.checkbox.otherValueFun('')
									},500)
								}
								console.log(qtArrq,69111111)
								_this.items = result;
								if (paperId == 5) {
									_this.$refs['checkbox'].cascadeShow()
								}
								// else if(paperId == 7){
								// 	_this.$refs['checkbox'].cascadeShowc()
								// }
								else {
									_this.$refs['checkbox'].show()
								}
							} else if (itemType == 5) { //时间

							} else if (itemType == 7) {

							}
						}
					}).catch(err => {})
			},
			userArchives() {
				this.loadingone = true;
				let _this = this;
				this.$api.get(global.apiUrls.userArchives + '/' + uni.getStorageSync(global.IS_DEV?'USER_DATA_BSY_T':'USER_DATA_BSY_Z').userId, {})
					.then(res => {
						if (res.data.code == 1000) {
							let result = res.data.result;
							_this.result = result;
							let weight = result.basicInfo.weight+'';
							_this.value1 = result.basicInfo.birthday
							if(weight){
								let strIndex = weight.indexOf(".") //.的索引
								console.log(strIndex,weight,'67777777')
								if (weight.startsWith('.', strIndex)) {//有.
								     weight = weight.split('.')
									_this.value2 = [weight[0]*1,weight[1]*1, 'kg']
								}else{
									_this.value2 = [result.basicInfo.weight, 'kg']
								}
							}
							console.log(result.basicInfo.weight,'674444444')
							_this.value3 = [result.basicInfo.height, 'cm']
							this.isLoadingOver = true;
						}
						_this.loadingone = false;
					}).catch(err => {})
			},
			clickInput(name) {
				console.log(name, 104)
				switch (name) {
					case 'birthday':
						name = 'picker1';
						break;
					case 'height':
						name = 'picker3';
						break;
					case 'weight':
						name = 'picker2';
						break;
					case 'bloodType':
						name = 'picker5';
						break;
					case 'gender':
						name = 'picker4';
						break;
					case 'bmi':
						uni.showToast({
							title: 'bmi不可修改',
							icon: 'none',
							duration: 2000
						});
						return
					default:
						return
				}
				this.$refs[name].show()
			},
			handleTap(name) {
				this.$refs[name].show()
			},
			handleChange(e) {
				console.log('change::', e)
			},
			handleConfirm(e) {
				console.log(e)
			},
			handleCancel(e) {
				console.log('cancel::', e)
			}
		}
	}
</script>

<style lang="scss">
	// 健康信息内容
	.wview-body {
		padding: 0 20upx;

		.flex-titlea {
			font-size: 30upx;
			height: 80upx;
			line-height: 80upx;
		}

		.wview-flex {
			display: flex;
			padding-bottom: 30upx;

			.flex-leftView,
			.flex-rView {
				width: 50%;
				font-size: 26upx;
			}
		}
	}

	.w706 {
		width: 706upx;
		margin: 30upx auto 0;
		background: #fff;
		border-radius: 25upx;
	}

	.materials-title {
		height: 90upx;
		line-height: 90upx;
		padding: 0 20upx;
		background: linear-gradient(112deg, #81C042 0%, #2EA7E0 100%);
		opacity: 0.23;
		border-radius: 25upx 25upx 0 0;
	}

	.materials-title2 {
		height: 40upx;
		line-height: 40upx;
		transform: translateY(-60upx);
		color: #2EA7E0;
		padding-left: 20upx;
		margin-bottom: -40upx;
	}

	.materia {
		height: 90upx;
		padding: 0 20upx;
		line-height: 90upx;

		.flex-title {
			width: 46%;
			font-size: 28upx;
			font-weight: 400;
			color: #333333;
		}

		.flex-num {
			width: 49%;
			font-weight: 500;
			color: #333333;
			text-align: right;

			.flex-input {
				height: 90upx;
				line-height: 90upx;
				font-size: 28upx;
			}

		}

		.optional {
			position: relative;
			// padding-right: 40upx;
		}

		.optional:before {
			content: '';
			position: absolute;
			top: 30upx;
			right: -36upx;
			width: 30upx;
			height: 30upx;
			background: url(https://bsyjk-pic.bsyjk.cn/arrows/1CB6DDEEB08E4CE0A40E8E86A99D1A0D.png)no-repeat;
			background-size: 30upx 30upx;
		}
	}

	.packUp {
		height: 90upx;
		line-height: 90upx;
		text-align: center;
		font-size: 22upx;
		font-weight: 400;
		color: #9B9B9B;

		.clickhide {
			position: relative;
		}

		.clickhide:before {
			content: '';
			width: 25upx;
			height: 25upx;
			position: absolute;
			top: 0;
			left: -30upx;
			transform: rotate(-180deg);
			background: url(https://bsyjk-pic.bsyjk.cn/duigicon/FBA5BD95CF0D4F7C838CDCBBB8A21DBC.png)no-repeat;
			background-size: 25upx 25upx;

		}
	}

	.message-box {
		width: 702upx;
		background: #FFFFFF;
		border-radius: 16upx;
		margin: 30upx auto 0;
		padding: 27upx 20upx 31upx;
		position: relative;

		.title-dn {
			font-size: 30upx;
			font-weight: 500;
			color: #2EA7E0;
			line-height: 42upx;
		}

		.perfect-text {
			font-size: 24upx;
			font-weight: 400;
			color: #9B9B9B;
			line-height: 33upx;
		}
	}

	.message-box::before {
		content: '';
		position: absolute;
		top: 50%;
		transform: translateY(-50%);
		right: 21upx;
		width: 36upx;
		height: 36upx;
		background: url(https://bsyjk-pic.bsyjk.cn/arrows/1CB6DDEEB08E4CE0A40E8E86A99D1A0D.png)no-repeat;
		background-size: 36upx 36upx;
	}

	.reportView {
		height: 131upx;
		display: flex;
		padding: 26upx 22upx;

		.report-icon {
			width: 50upx;
			height: 50upx;
			margin-top: 10upx;
		}

		.report-c {
			width: 500upx;
			padding-left: 20upx;
			font-size: 24upx;
			font-weight: 400;
			color: #333333;
			line-height: 33upx;

			.report-title {
				font-size: 30upx;
				font-weight: 400;
				color: #333333;
				line-height: 42upx;
			}
		}

		.report-r {
			height: 42px;
			font-size: 30upx;
			font-weight: 500;
			color: #F56767;
			padding-top: 20upx;

			.color-wc {
				color: #81C042;
			}

			.color-jd {
				color: #2EA7E0;
			}

			.report-result {
				position: relative;
			}

			.report-result:before {
				content: '';
				position: absolute;
				top: 6upx;
				right: -30upx;
				width: 30upx;
				height: 30upx;
				background: url(https://bsyjk-pic.bsyjk.cn/arrows/1CB6DDEEB08E4CE0A40E8E86A99D1A0D.png)no-repeat;
				background-size: 30upx 30upx;
			}
		}
	}

	.uploading-view {
		width: 610upx;
		height: 130upx;
		background: #FFFFFF;
		border-radius: 16upx;
		margin: 48upx auto;
		border: 1px dashed #979797;
		text-align: center;
		line-height: 130upx;
		font-size: 30upx;
		font-weight: 400;
		color: #4A4A4A;

		.uploading-pr {
			position: relative;
			padding-left: 44upx;
		}

		.uploading-pr:before {
			content: '';
			width: 44upx;
			height: 44upx;
			position: absolute;
			top: -4upx;
			left: -10upx;
			background: url(http://static.bsyjk.cn/addicon/0F46361D18614466A2185208E4386416.png)no-repeat;
			background-size: 44upx 44upx;

		}
	}
</style>
